package com.huli.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.huli.domain.PropertyCompany;
import com.huli.dto.GarageIncomeDto;
import com.huli.dto.PropertyCompanyDto;
import com.huli.param.PropertyCompanyParam;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface PropertyCompanyMapper extends BaseMapper<PropertyCompany> {

    //通过物业id查询物业日收入
    @Select("SELECT garage.property_company_id  propertyCompanyId,YEAR(garage_income_timed) year,MONTH(garage_income_timed) month,\tDAY(garage_income_timed) day,SUM(garage_income_money) income FROM garage,garage_income WHERE\t\n" +
            "garage_income.garage_id = garage.garage_id \n" +
            "AND YEAR(garage_income_timed)=#{year} \n" +
            "AND MONTH(garage_income_timed)=#{month} \n" +
            "AND DAY(garage_income_timed)=#{day}\n" +
            "GROUP BY garage.property_company_id,year,month,day  \n" +
            "HAVING garage.property_company_id=#{propertyCompanyId}\n" +
            "\t")
    public PropertyCompanyDto selectPropertyDayIncomeById(PropertyCompanyParam propertyCompanyParam);



    //通过物业id查询车库日收入
    @Select("SELECT garage.property_company_id  propertyCompanyId,garage.garage_id  garageId,YEAR(garage_income_timed) year,MONTH(garage_income_timed) month,\tDAY(garage_income_timed) day,garage_income_money income\n" +
            "FROM garage,garage_income WHERE\t\n" +
            "garage_income.garage_id = garage.garage_id \n" +
            "AND YEAR(garage_income_timed)=#{year} \n" +
            "AND MONTH(garage_income_timed)=#{month} \n" +
            "AND DAY(garage_income_timed)=#{day}\n" +
            "GROUP BY garage.property_company_id,garage.garage_id,year,month,day,garage_income_money  \n" +
            "HAVING garage.property_company_id=#{propertyCompanyId}")
    public List<GarageIncomeDto> selectGarageDayIncomeById(PropertyCompanyParam propertyCompanyParam);
}
